# -*- coding: utf-8 -*-

################################################################################
## Form generated from reading UI file '使用进度条组件模拟跑马灯效果.ui'
##
## Created by: Qt User Interface Compiler version 5.15.2
##
## WARNING! All changes made in this file will be lost when recompiling UI file!
################################################################################

from PySide2.QtCore import *
from PySide2.QtGui import *
from PySide2.QtWidgets import *
from PySide2 import QtWidgets, QtCore, QtGui
import sys


class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        if not MainWindow.objectName():
            MainWindow.setObjectName(u"MainWindow")
        MainWindow.resize(800, 600)
        self.centralwidget = QWidget(MainWindow)
        self.centralwidget.setObjectName(u"centralwidget")

        self.progressBar = QProgressBar(self.centralwidget)
        self.progressBar.setObjectName(u"progressBar")
        self.progressBar.setGeometry(QRect(270, 120, 321, 31))
        self.progressBar.setValue(24)
        # 对顶部的进度条组件进行修改属性
        self.progressBar.setProperty("value", -1)
        self.progressBar.setTextVisible(True)
        self.progressBar.setFormat("")
        self.progressBar.setTextDirection(QtWidgets.QProgressBar.TopToBottom)

        self.progressBar_2 = QProgressBar(self.centralwidget)
        self.progressBar_2.setObjectName(u"progressBar_2")
        self.progressBar_2.setGeometry(QRect(230, 120, 41, 271))
        self.progressBar_2.setValue(24)
        self.progressBar_2.setOrientation(Qt.Vertical)
        # 设置左侧的进度条组件
        self.progressBar_2.setProperty("value", -1)
        self.progressBar_2.setTextVisible(True)
        self.progressBar_2.setTextDirection(QtWidgets.QProgressBar.TopToBottom)

        self.progressBar_3 = QProgressBar(self.centralwidget)
        self.progressBar_3.setObjectName(u"progressBar_3")
        self.progressBar_3.setGeometry(QRect(230, 390, 361, 41))
        self.progressBar_3.setValue(24)
        # 对底部进度条进行属性设置
        self.progressBar_3.setProperty("value", -1)
        self.progressBar_3.setTextVisible(True)
        self.progressBar_3.setTextDirection(QtWidgets.QProgressBar.TopToBottom)

        self.progressBar_4 = QProgressBar(self.centralwidget)
        self.progressBar_4.setObjectName(u"progressBar_4")
        self.progressBar_4.setGeometry(QRect(550, 120, 41, 311))
        self.progressBar_4.setValue(24)
        self.progressBar_4.setOrientation(Qt.Vertical)
        # 设置右侧进度条属性
        self.progressBar_4.setProperty("value", -1)
        self.progressBar_4.setTextVisible(True)
        self.progressBar_4.setTextDirection(QtWidgets.QProgressBar.TopToBottom)

        self.pushButton = QPushButton(self.centralwidget)
        self.pushButton.setObjectName(u"pushButton")
        self.pushButton.setGeometry(QRect(360, 470, 121, 31))

        MainWindow.setCentralWidget(self.centralwidget)

        self.timer = QtCore.QBasicTimer()     # 创建计时器对象
        # 为按钮绑定单击信号
        self.pushButton.clicked.connect(self.running)

        self.menubar = QMenuBar(MainWindow)
        self.menubar.setObjectName(u"menubar")
        self.menubar.setGeometry(QRect(0, 0, 800, 26))
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QStatusBar(MainWindow)
        self.statusbar.setObjectName(u"statusbar")
        MainWindow.setStatusBar(self.statusbar)

        self.retranslateUi(MainWindow)

        QMetaObject.connectSlotsByName(MainWindow)
    # setupUi

    def retranslateUi(self, MainWindow):
        MainWindow.setWindowTitle(QCoreApplication.translate("MainWindow", u"\u4f7f\u7528\u8fdb\u5ea6\u6761\u7ec4\u4ef6\u6a21\u62df\u8dd1\u9a6c\u706f\u6548\u679c", None))
        self.pushButton.setText(QCoreApplication.translate("MainWindow", u"\u5f00\u59cb", None))


    # 控制进度条的滚动效果
    def running(self):
        if self.timer.isActive():
            self.timer.stop()
            self.pushButton.setText("开始")
            # 设置4个进度条的最大值为100
            self.progressBar.setMaximum(100)
            self.progressBar_2.setMaximum(100)
            self.progressBar_3.setMaximum(100)
            self.progressBar_4.setMaximum(100)
        else:
            self.timer.start(100, MainWindow)
            self.pushButton.setText("停止")
            # 将四个进度条的最大值和最小值都设为0，以便显示魂环滚动的效果
            self.progressBar.setMinimum(0)
            self.progressBar.setMaximum(0)
            self.progressBar_2.setInvertedAppearance(True)
            self.progressBar_2.setMinimum(0)
            self.progressBar_2.setMaximum(0)
            self.progressBar_3.setMinimum(0)
            self.progressBar_3.setMaximum(0)
            self.progressBar_4.setMinimum(0)
            self.progressBar_4.setMaximum(0)



# 界面启动程序
if __name__ == '__main__':
    app = QtWidgets.QApplication(sys.argv)
    MainWindow = QtWidgets.QMainWindow()
    ui = Ui_MainWindow()
    ui.setupUi(MainWindow)
    MainWindow.show()
    sys.exit(app.exec_())


